package lumis.service.wsrp.producer;

import lumis.doui.control.ControlContainer;
import lumis.doui.control.IControl;
import lumis.doui.control.dropdownlist.DropDownListControl;
import lumis.portal.PortalException;
import lumis.service.wsrp.common.WSRPVersionFromTo;
import lumis.util.XmlUtil;

import org.w3c.dom.Node;

import com.sun.portal.wsrp.producer.ProducerVersion;

/**
 * {@link DropDownListControl} that populates itself with the values contained
 * into the enum {@link ProducerVersion}. They are {@link ProducerVersion#BOTH},
 * {@link ProducerVersion#VERSION1} and {@link ProducerVersion#VERSION2}. It
 * displays a localized friendly name to the final user.
 * 
 * @version $Revision: 11180 $ $Date: 2009-12-04 18:13:02 -0200 (Fri, 04 Dec 2009) $
 * @since 5.5.0
 */
public class ProducerConfigurationInterfaceVersionDropDownListControl extends DropDownListControl
{
	@Override
	public void init(Node controlDefinitionNode, ControlContainer controlContainer, IControl parentControl) throws PortalException
	{
		super.init(controlDefinitionNode, controlContainer, parentControl);

		// adds the FromTo values to the interface
		for (WSRPVersionFromTo fromTo : WSRPVersionFromTo.values())
		{
			Node optionNode = XmlUtil.addTextNode(controlDefinitionNode, "option", localize(fromTo.getLocalizableName()));
			XmlUtil.addNodeAttr(optionNode, "value", fromTo.getValue());
		}
	}
}
